package com.sc.nft.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserEcologyExpenditureRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sc.nft.entity.vo.ecology.EcologyExpenditureRecordVO;
import com.sc.nft.entity.vo.ecology.ExpendEcologyCastRecordsVO;
import com.sc.nft.entity.vo.ecology.UserEcologyDetailVO;
import com.sc.nft.entity.vo.ecology.UserEcologyExpenditureRecordPageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 生态-用户-收入记录表(sc_user_ecology_expenditure_record)数据Mapper
 *
 * @author Sun
 * @since 2023-10-20 17:57:13
 * @description 由 Mybatisplus Code Generator 创建
*/
@Mapper
public interface UserEcologyExpenditureRecordMapper extends BaseMapper<UserEcologyExpenditureRecord> {

    /**
     * 分页获取收入记录
     * @param page
     * @param userId
     * @return
     */
    Page<EcologyExpenditureRecordVO> ecologyExpenditureRecord(Page page, @Param("userId") Long userId);

    /**
     * 平台总发放
     * @return
     */
    @Select("select IFNULL(sum(link_count),0) from sc_user_ecology_expenditure_record where type =1 and is_delete = 0 AND create_time < CURDATE( )" )
    BigDecimal getSumHatchTotalPlatformDistribution();

    /**
     * 获取昨天的总发放
     * @return
     */
    @Select("select IFNULL(sum(link_count),0) from sc_user_ecology_expenditure_record where type =1 and is_delete = 0 AND DATEDIFF(create_time,NOW())=-1")
    BigDecimal getYesterDaySumEcologyPoints();

    /**
     * 获取燃料释放
     * @param startTime
     * @param endTime
     * @return
     */
    BigDecimal getFuelReleaseByStartTimeAndEndTime(@Param("startTime") Date startTime,@Param("endTime") Date endTime);

    /**
     * 分页获取支出明细
     * @param page
     * @param userId
     * @return
     */
    Page<UserEcologyDetailVO> userEcologyDetail(Page page, @Param("userId") Long userId);

    /**
     * 获取用户收入记录汇总
     * @param page
     * @param userId
     * @param type
     * @return
     */
    Page<UserEcologyExpenditureRecordPageVO> userEcologyExpenditureRecordPage(Page page, @Param("userId") Long userId,@Param("type") int type,@Param("linkId") Long linkId);

    /**
     * 获取用户收入记录明细
     * @param page
     * @param userId
     * @param type
     * @param dateTime
     * @return
     */
    Page<EcologyExpenditureRecordVO> userEcologyExpenditureRecordDetailsPage(Page page,@Param("userId") Long userId, @Param("type") int type,@Param("dateTime") Integer dateTime,@Param("linkId") Long linkId);

}
